{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example - Executing a notebook from the Command Line"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How to add a parameter tag\n",
    "\n",
    "If you wanted to add your own parameter tag, you would go to the menu: View ➡️ Cell Toolbar ➡️ Tags\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Input notebook\n",
    "\n",
    "Let's take a look at the input notebook (`simple_input.ipynb`). This notebook has cells containing\n",
    "tags for the parameters. \n",
    "\n",
    "[See input notebook](simple_input.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Execute using the Command Line\n",
    "\n",
    "We are going to use the Jupyter magic `%%bash` to simulate executing the notebook from\n",
    "the command line from a bash terminal.\n",
    "\n",
    "The command takes the form:\n",
    "\n",
    "`papermill <input notebook> <output notebook> -p <parameter name> <parameter value>`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "parameters"
    ]
   },
   "outputs": [],
   "source": [
    "binder_dir = '..'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!papermill {binder_dir}/cli-simple/simple_input.ipynb {binder_dir}/cli-simple/simple_output.ipynb -p msg 'Hello'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Output notebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's take a look at the output notebook.\n",
    "\n",
    "[See output notebook](simple_output.ipynb)"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
